[jboss-cvs] JBossAS SVN: r64339 - in projects/microcontainer/trunk/kernel/src: resources/tests/org/jboss/test/kernel/inject/test and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Jul 29 16:36:50 EDT 2007


Author: alesj
Date: 2007-07-29 16:36:49 -0400 (Sun, 29 Jul 2007)
New Revision: 64339

Added:
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SomeGenericObject.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/StringValueObject.java
Modified:
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractFeatureMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractPropertyMetaData.java
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/GenericsContextualInjection.xml
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/GenericsTestObject.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/GenericsContextualInjectionTestCase.java
Log:
Generics support. Checking collections only.

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractFeatureMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractFeatureMetaData.java	2007-07-28 21:28:57 UTC (rev 64338)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractFeatureMetaData.java	2007-07-29 20:36:49 UTC (rev 64339)
@@ -107,16 +107,17 @@
    protected TypeInfo applyCollectionOrMapCheck(TypeInfo typeInfo) throws Throwable
    {
       TypeInfoFactory tif = typeInfo.getTypeInfoFactory();
-      boolean isMapTypeInfo = tif.getTypeInfo(Map.class).isAssignableFrom(typeInfo);
+      boolean isCollectionType = tif.getTypeInfo(Collection.class).isAssignableFrom(typeInfo);
       // cannot determine on map, since we don't know if we are key or value
-      if (typeInfo instanceof ClassInfo && isMapTypeInfo == false)
+      if (typeInfo instanceof ClassInfo && isCollectionType)
       {
          ClassInfo classInfo = (ClassInfo)typeInfo;
          TypeInfo[] types = classInfo.getActualTypeArguments();
          if (types != null)
             return types[0];
       }
-      if (tif.getTypeInfo(Collection.class).isAssignableFrom(typeInfo) || isMapTypeInfo)
+      boolean isMapTypeInfo = tif.getTypeInfo(Map.class).isAssignableFrom(typeInfo);
+      if (isCollectionType || isMapTypeInfo)
       {
          throw new IllegalArgumentException("Should not be here - set element/value class type in collection/map: " + this);
       }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractPropertyMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractPropertyMetaData.java	2007-07-28 21:28:57 UTC (rev 64338)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractPropertyMetaData.java	2007-07-29 20:36:49 UTC (rev 64339)
@@ -22,7 +22,6 @@
 package org.jboss.beans.metadata.plugins;
 
 import java.io.Serializable;
-import java.util.Iterator;
 import java.util.Set;
 
 import org.jboss.beans.info.spi.PropertyInfo;
@@ -34,8 +33,8 @@
 import org.jboss.kernel.plugins.config.Configurator;
 import org.jboss.kernel.spi.config.KernelConfigurator;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.util.JBossStringBuilder;
 import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.util.JBossStringBuilder;
 
 /**
  * Metadata for a property.
@@ -190,12 +189,11 @@
       }
       // check properties
       KernelControllerContext context = visitor.getControllerContext();
-      Set propertyInfos = context.getBeanInfo().getProperties();
-      if (propertyInfos != null)
+      Set<PropertyInfo> propertyInfos = context.getBeanInfo().getProperties();
+      if (propertyInfos != null && propertyInfos.isEmpty() == false)
       {
-         for(Iterator it = propertyInfos.iterator(); it.hasNext();)
+         for (PropertyInfo pi : propertyInfos)
          {
-            PropertyInfo pi = (PropertyInfo) it.next();
             if (getName().equals(pi.getName()))
             {
                return applyCollectionOrMapCheck(pi.getType());

Modified: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/GenericsContextualInjection.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/GenericsContextualInjection.xml	2007-07-28 21:28:57 UTC (rev 64338)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/GenericsContextualInjection.xml	2007-07-29 20:36:49 UTC (rev 64339)
@@ -1,10 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-            xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
-            xmlns="urn:jboss:bean-deployer">
+            xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
+            xmlns="urn:jboss:bean-deployer:2.0">
 
    <bean name="testObject" class="org.jboss.test.kernel.inject.support.GenericsTestObject">
+      <property name="generic">
+         <inject/>
+      </property>
       <property name="collection">
          <collection><inject/></collection>
       </property>
@@ -18,4 +21,10 @@
 
    <bean name="duplicateTester" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
 
+   <bean name="gso" class="org.jboss.test.kernel.inject.support.StringValueObject">
+      <constructor>
+         <parameter>SomeString</parameter>
+      </constructor>
+   </bean>
+
 </deployment>

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/GenericsTestObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/GenericsTestObject.java	2007-07-28 21:28:57 UTC (rev 64338)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/GenericsTestObject.java	2007-07-29 20:36:49 UTC (rev 64339)
@@ -33,6 +33,7 @@
    private Collection<TesterInterface> collection;
    private Set<TesterInterface> set;
    private List<TesterInterface> list;
+   private SomeGenericObject<String> generic;
 
    public Collection<TesterInterface> getCollection()
    {
@@ -63,4 +64,14 @@
    {
       this.list = list;
    }
+
+   public SomeGenericObject<String> getGeneric()
+   {
+      return generic;
+   }
+
+   public void setGeneric(SomeGenericObject<String> generic)
+   {
+      this.generic = generic;
+   }
 }

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SomeGenericObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SomeGenericObject.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/SomeGenericObject.java	2007-07-29 20:36:49 UTC (rev 64339)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* 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.kernel.inject.support;
+
+/**
+ * @param <T> exact type
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class SomeGenericObject<T>
+{
+   private T value;
+
+   public SomeGenericObject(T value)
+   {
+      this.value = value;
+   }
+
+   public T getValue()
+   {
+      return value;
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/StringValueObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/StringValueObject.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/StringValueObject.java	2007-07-29 20:36:49 UTC (rev 64339)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* 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.kernel.inject.support;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class StringValueObject extends SomeGenericObject<String>
+{
+   public StringValueObject(String value)
+   {
+      super(value);
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/GenericsContextualInjectionTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/GenericsContextualInjectionTestCase.java	2007-07-28 21:28:57 UTC (rev 64338)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/GenericsContextualInjectionTestCase.java	2007-07-29 20:36:49 UTC (rev 64339)
@@ -57,6 +57,7 @@
       checkCollection(testBean.getCollection(), tester);
       checkCollection(testBean.getList(), tester);
       checkCollection(testBean.getSet(), tester);
+      assertNotNull(testBean.getGeneric());
    }
 
    protected void checkCollection(Collection<TesterInterface> collection, TesterInterface tester)




More information about the jboss-cvs-commits mailing list