geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r775978 - in /geronimo/sandbox/blueprint/blueprint-core/src: main/java/org/apache/geronimo/blueprint/context/ main/java/org/apache/geronimo/blueprint/convert/ main/java/org/apache/xbean/recipe/ test/java/org/apache/geronimo/blueprint/ test/...
Date Mon, 18 May 2009 14:55:24 GMT
Author: gnodet
Date: Mon May 18 14:55:23 2009
New Revision: 775978

URL: http://svn.apache.org/viewvc?rev=775978&view=rev
Log:
Remove Recipe.getTypes() which is not needed anymore, fix unit tests

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ValueRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/convert/ConversionServiceImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ArrayRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/MapRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/Recipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ReferenceNameRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/TestBlueprintContext.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
Mon May 18 14:55:23 2009
@@ -617,15 +617,6 @@
         }
     }
 
-    public Type[] getTypes() {
-        Class type = getType();
-        if (type != null) {
-            return new Type[] { getType() };
-        } else{
-            return new Type[] { Object.class };
-        }
-    }
-
     public void setProperties(Object instance) throws ConstructionException {
         // clone the properties so they can be used again
         Map<String,Object> propertyValues = new LinkedHashMap<String,Object>(properties);
@@ -675,7 +666,7 @@
             Type type = setter.getGenericParameterTypes()[0];
             // Instanciate value
             if (propertyValue instanceof Recipe) {
-                propertyValue = ((Recipe) propertyValue).create(type, false);
+                propertyValue = ((Recipe) propertyValue).create(Object.class, false);
             }
             try {
                 propertyValue = convert(propertyValue, type);

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
Mon May 18 14:55:23 2009
@@ -71,10 +71,6 @@
         this.comparatorRecipe = comparatorRecipe;
     }
 
-    public Type[] getTypes() {
-        return new Type[] { metadata.getCollectionType() };
-    }
-
     @Override
     protected Object internalCreate(Type expectedType, boolean lazyRefAllowed) throws ConstructionException
{
         Comparator comparator = null;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java
Mon May 18 14:55:23 2009
@@ -293,7 +293,7 @@
             Class cl = collectionMetadata.getCollectionClass();
             Class type = loadClass(collectionMetadata.getValueTypeName());
             if (cl == Object[].class) {
-                ArrayRecipe ar = new ArrayRecipe(type);
+                ArrayRecipe ar = new ArrayRecipe(getConversionService(), type);
                 for (Metadata lv : collectionMetadata.getValues()) {
                     ar.add(getValue(lv, type));
                 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ReferenceRecipe.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ReferenceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ReferenceRecipe.java
Mon May 18 14:55:23 2009
@@ -64,24 +64,6 @@
         return getNestedRecipes();
     }
 
-    public Type[] getTypes() {
-        if (referenceName == null) {
-            throw new ConstructionException("Reference name has not been set");
-        }
-        
-        ExecutionContext context = ExecutionContext.getContext();
-        
-        Object object = context.getObject(referenceName);
-        if (object instanceof Recipe) {
-            Recipe recipe = (Recipe) object;
-            return recipe.getTypes();
-        } else if (object instanceof ServiceReferenceAccessor) {
-            return new Type[] { object.getClass(), ServiceReference.class };
-        } else {
-            return new Type[] { object != null ? object.getClass() : Object.class };
-        }
-    }
-    
     protected Object internalCreate(Type expectedType, boolean lazyRefAllowed) throws ConstructionException
{
         if (referenceName == null) {
             throw new ConstructionException("Reference name has not been set");

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java
Mon May 18 14:55:23 2009
@@ -108,15 +108,6 @@
         return list;
     }
     
-    public Type[] getTypes() {
-        try {
-            List<Class> interfaceList = getSupportedTypes();
-            return (Type[]) interfaceList.toArray(new Type [interfaceList.size()]);
-        } catch (ClassNotFoundException e) {
-            throw new ConstructionException(e);
-        }
-    }
-
     @Override
     public void stop() {
         super.stop();

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ValueRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ValueRecipe.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ValueRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ValueRecipe.java
Mon May 18 14:55:23 2009
@@ -62,16 +62,6 @@
         }
     }
 
-    public Type[] getTypes() {
-        if (type != null) {
-            return new Type[] { type };
-        //} else if (value.getTypeName() != null) {
-            // TODO
-        } else {
-            return new Type[] { String.class };
-        }
-    }
-
     public String toString() {
         return "ValueRecipe: " + type + " " + value.getStringValue();
     }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/convert/ConversionServiceImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/convert/ConversionServiceImpl.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/convert/ConversionServiceImpl.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/convert/ConversionServiceImpl.java
Mon May 18 14:55:23 2009
@@ -200,7 +200,7 @@
 
     private static Object createObject(String value, Class type) throws Exception {
         if (type.isInterface() || Modifier.isAbstract(type.getModifiers())) {
-            throw new Exception("Unable to convert. Type class is an interface or is an abstract
class");
+            throw new Exception("Unable to convert value " + value + " to type " + type +
". Type " + type + " is an interface or an abstract class");
         }
         Constructor constructor = null;
         try {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ArrayRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ArrayRecipe.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ArrayRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ArrayRecipe.java
Mon May 18 14:55:23 2009
@@ -24,6 +24,9 @@
 import java.util.EnumSet;
 import java.util.List;
 
+import org.osgi.service.blueprint.convert.ConversionService;
+import org.apache.geronimo.blueprint.utils.ConversionUtils;
+
 /**
  * @version $Rev$ $Date$
  */
@@ -31,22 +34,14 @@
     private final List<Recipe> list;
     private Class typeClass;
     private final EnumSet<Option> options = EnumSet.noneOf(Option.class);
+    private final ConversionService conversionService;
 
-    public ArrayRecipe() {
-        list = new ArrayList<Recipe>();
-    }
-
-    public ArrayRecipe(Class type) {
+    public ArrayRecipe(ConversionService conversionService, Class type) {
+        this.conversionService = conversionService;
         this.list = new ArrayList<Recipe>();
         this.typeClass = type;
     }
 
-    public ArrayRecipe(ArrayRecipe collectionRecipe) {
-        if (collectionRecipe == null) throw new NullPointerException("setRecipe is null");
-        this.typeClass = collectionRecipe.typeClass;
-        list = new ArrayList<Recipe>(collectionRecipe.list);
-    }
-
     public void allow(Option option) {
         options.add(option);
     }
@@ -73,16 +68,8 @@
         return Collections.emptyList();
     }
 
-    public Type[] getTypes() {
-        if (typeClass != null) {
-            return new Type[] { typeClass };
-        } else {
-            return new Type[] { Object[].class };
-        }
-    }
-
     protected Object internalCreate(Type expectedType, boolean lazyRefAllowed) throws ConstructionException
{
-        Class type = getType(expectedType);
+        Class type = typeClass != null ? typeClass : Object.class;
 
         // create array instance
         Object array;
@@ -101,7 +88,16 @@
 
         int index = 0;
         for (Recipe recipe : list) {
-            Object value = recipe != null ? recipe.create(type, refAllowed) : null;
+            Object value;
+            if (recipe != null) {
+                try {
+                    value = ConversionUtils.convert(recipe.create(Object.class, refAllowed),
type, conversionService);
+                } catch (Exception e) {
+                    throw new ConstructionException("Unable to convert value " + recipe +
" to type " + type, e);
+                }
+            } else {
+                value = null;
+            }
             
             if (value instanceof Reference) {
                 Reference reference = (Reference) value;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java
Mon May 18 14:55:23 2009
@@ -105,21 +105,6 @@
         return Collections.emptyList();
     }
 
-    public Type[] getTypes() {
-        Class type = typeClass;
-        if (type == null && typeName != null) {
-            try {
-                type = RecipeHelper.loadClass(typeName);
-            } catch (ClassNotFoundException e) {
-                throw new ConstructionException("Type class could not be found: " + typeName);
-            }
-        }
-        if (type == null) {
-            type = Collection.class;
-        }
-        return new Type[] { type };
-    }
-
     protected Object internalCreate(Type expectedType, boolean lazyRefAllowed) throws ConstructionException
{
         Class type = getType(expectedType);
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/MapRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/MapRecipe.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/MapRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/MapRecipe.java
Mon May 18 14:55:23 2009
@@ -107,10 +107,6 @@
         return Collections.emptyList();
     }
 
-    public Type[] getTypes() {
-        return new Type[] { typeClass };
-    }
-
     protected Object internalCreate(Type expectedType, boolean lazyRefAllowed) throws ConstructionException
{
         Class mapType = getType(expectedType);
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/Recipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/Recipe.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/Recipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/Recipe.java
Mon May 18 14:55:23 2009
@@ -26,8 +26,6 @@
 public interface Recipe extends Serializable {
     String getName();
 
-    Type[] getTypes();
-
     Object create() throws ConstructionException;
     Object create(ClassLoader classLoader) throws ConstructionException;
     Object create(Type expectedType, boolean lazyRefAllowed) throws ConstructionException;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ReferenceNameRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ReferenceNameRecipe.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ReferenceNameRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ReferenceNameRecipe.java
Mon May 18 14:55:23 2009
@@ -69,10 +69,6 @@
         return getNestedRecipes();
     }
 
-    public Type[] getTypes() {
-        return new Type[] { String.class };
-    }
-
     protected Object internalCreate(Type expectedType, boolean lazyRefAllowed) throws ConstructionException
{
         Object object = getReference();
         return referenceName;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ReferenceRecipe.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ReferenceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ReferenceRecipe.java
Mon May 18 14:55:23 2009
@@ -57,20 +57,6 @@
         return getNestedRecipes();
     }
 
-    public Type[] getTypes() {
-        if (referenceName == null) {
-            throw new ConstructionException("Reference name has not been set");
-        }
-        ExecutionContext context = ExecutionContext.getContext();
-        Object object = context.getObject(referenceName);
-        if (object instanceof Recipe) {
-            Recipe recipe = (Recipe) object;
-            return recipe.getTypes();
-        } else {
-            return new Type[] { object != null ? object.getClass() : Object.class };
-        }
-    }
-
     protected Object internalCreate(Type expectedType, boolean lazyRefAllowed) throws ConstructionException
{
         if (referenceName == null) {
             throw new ConstructionException("Reference name has not been set");

Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/TestBlueprintContext.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/TestBlueprintContext.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/TestBlueprintContext.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/TestBlueprintContext.java
Mon May 18 14:55:23 2009
@@ -26,7 +26,7 @@
     private ComponentDefinitionRegistryImpl registry;
     
     public TestBlueprintContext(ComponentDefinitionRegistryImpl registry) {
-        super(new TestBundleContext(), null, null, null, null, false);
+        super(new TestBundleContext(), null, null, null, null, null, false);
         this.registry = registry;
     }
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java
Mon May 18 14:55:23 2009
@@ -237,12 +237,13 @@
         Object obj8 = graph.create("multipleString");
         testMultiple(obj8, "123", -1, null);
 
-        try {
-            graph.create("multipleStringConvertable");
-            fail("Did not throw exception");
-        } catch (RuntimeException e) {
-            // we expect exception
-        }
+        // TODO: check the below tests when the incoherence between TCK / spec is solved
+//        try {
+//            graph.create("multipleStringConvertable");
+//            fail("Did not throw exception");
+//        } catch (RuntimeException e) {
+//            // we expect exception
+//        }
         
         Object obj10 = graph.create("multipleFactory1");
         testMultiple(obj10, null, 1234, null);

Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml?rev=775978&r1=775977&r2=775978&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml Mon May 18
14:55:23 2009
@@ -76,11 +76,11 @@
             </array>
         </property>
         <property name="numberArray">
-            <array value-type="java.lang.Integer">
-                <value>1</value>
+            <array>
+                <value type="int">1</value>
                 <value type="java.math.BigInteger">50</value>
                 <value type="java.lang.Long">100</value>
-                <value>200</value>
+                <value type="int">200</value>
             </array>
         </property>
         <property name="number">



Mime
View raw message