You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gn...@apache.org on 2009/05/13 15:09:33 UTC

svn commit: r774319 - in /geronimo/sandbox/blueprint: ./ blueprint-bundle/ blueprint-core/ blueprint-core/src/main/java/org/apache/xbean/ blueprint-core/src/main/java/org/apache/xbean/recipe/

Author: gnodet
Date: Wed May 13 13:09:33 2009
New Revision: 774319

URL: http://svn.apache.org/viewvc?rev=774319&view=rev
Log:
Inline xbean to be able to refactor the conversion mechanism and allow better matching of arguments against constructors / factory methods

Added:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/
      - copied from r774242, geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/
Removed:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/AsmParameterNameLoader.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/RecipeVisitor.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/StaticRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/UnsetPropertiesRecipe.java
Modified:
    geronimo/sandbox/blueprint/blueprint-bundle/pom.xml
    geronimo/sandbox/blueprint/blueprint-core/pom.xml
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/AbstractRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ObjectRecipe.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/RecipeHelper.java
    geronimo/sandbox/blueprint/pom.xml

Modified: geronimo/sandbox/blueprint/blueprint-bundle/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-bundle/pom.xml?rev=774319&r1=774318&r2=774319&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-bundle/pom.xml (original)
+++ geronimo/sandbox/blueprint/blueprint-bundle/pom.xml Wed May 13 13:09:33 2009
@@ -35,10 +35,6 @@
             <groupId>org.apache.geronimo</groupId>
             <artifactId>blueprint-cm</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.xbean</groupId>
-            <artifactId>xbean-reflect</artifactId>
-        </dependency>
     </dependencies>
 
     <build>
@@ -87,7 +83,6 @@
                         <configuration>
                             <artifactSet>
                                 <includes>
-                                    <include>org.apache.xbean:xbean-reflect</include>
                                     <include>asm:asm-all</include>
                                     <include>cglib:cglib</include>
                                     <include>org.apache.geronimo:blueprint-api</include>
@@ -97,12 +92,6 @@
                             </artifactSet>
                             <filters>
                                 <filter>
-                                    <artifact>org.apache.xbean:xbean-reflect</artifact>
-                                    <excludes>
-                                        <exclude>org/**</exclude>
-                                    </excludes>
-                                </filter>
-                                <filter>
                                     <artifact>asm:asm-all</artifact>
                                     <excludes>
                                         <exclude>org/**</exclude>

Modified: geronimo/sandbox/blueprint/blueprint-core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/pom.xml?rev=774319&r1=774318&r2=774319&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/pom.xml (original)
+++ geronimo/sandbox/blueprint/blueprint-core/pom.xml Wed May 13 13:09:33 2009
@@ -34,10 +34,6 @@
           <artifactId>blueprint-api</artifactId>
       </dependency>
       <dependency>
-          <groupId>org.apache.xbean</groupId>
-          <artifactId>xbean-reflect</artifactId>
-      </dependency>
-      <dependency>
           <groupId>org.apache.felix</groupId>
           <artifactId>org.osgi.core</artifactId>
       </dependency>

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/AbstractRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/AbstractRecipe.java?rev=774319&r1=774242&r2=774319&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/AbstractRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/AbstractRecipe.java Wed May 13 13:09:33 2009
@@ -41,10 +41,6 @@
         this.name = name;
     }
 
-    public float getPriority() {
-        return 0;
-    }
-
     public Object create() throws ConstructionException {
         return create(null);
     }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java?rev=774319&r1=774242&r2=774319&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java Wed May 13 13:09:33 2009
@@ -199,9 +199,6 @@
     }
     
     private void setProperty(Property key, Object value) {
-        if (value instanceof UnsetPropertiesRecipe) {
-            allow(Option.IGNORE_MISSING_PROPERTIES);
-        }
         properties.put(key, value);
     }
 
@@ -364,7 +361,7 @@
 
     private void setProperties(Map<Property, Object> propertyValues, Object instance, Class clazz) {
         // set remaining properties
-        for (Map.Entry<Property, Object> entry : RecipeHelper.prioritizeProperties(propertyValues)) {
+        for (Map.Entry<Property, Object> entry : propertyValues.entrySet()) {
             Property propertyName = entry.getKey();
             Object propertyValue = entry.getValue();
 

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=774319&r1=774242&r2=774319&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 Wed May 13 13:09:33 2009
@@ -26,8 +26,6 @@
 public interface Recipe extends Serializable {
     String getName();
 
-    float getPriority();
-
     boolean canCreate(Type type);
 
     Object create() throws ConstructionException;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/RecipeHelper.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/RecipeHelper.java?rev=774319&r1=774242&r2=774319&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/RecipeHelper.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/RecipeHelper.java Wed May 13 13:09:33 2009
@@ -30,7 +30,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.xbean.propertyeditor.PropertyEditors;
+import org.apache.geronimo.blueprint.convert.ConversionServiceImpl;
 
 /**
  * @version $Rev: 6687 $ $Date: 2005-12-28T21:08:56.733437Z $
@@ -85,12 +85,6 @@
 
     }
 
-    public static <K,V> List<Map.Entry<K,V>> prioritizeProperties(Map<K,V> properties) {
-        ArrayList<Map.Entry<K,V>> entries = new ArrayList<Map.Entry<K,V>>(properties.entrySet());
-        Collections.sort(entries, new RecipeComparator());
-        return entries;
-    }
-
     public static boolean isInstance(Type t, Object instance) {
         Class type = toClass(t);
         if (type.isPrimitive()) {
@@ -129,7 +123,8 @@
             Recipe recipe = (Recipe) propertyValue;
             return recipe.canCreate(type);
         }
-        return (propertyValue instanceof String && PropertyEditors.canConvert(toClass(type)));
+        throw new IllegalStateException();
+        //return (propertyValue instanceof String && PropertyEditors.canConvert(toClass(type)));
     }
 
     public static boolean isAssignableFrom(Class expected, Class actual) {
@@ -167,10 +162,10 @@
             value = recipe.create(expectedType, lazyRefAllowed);
         }
 
-        if (value instanceof String && (expectedType != Object.class)) {
-            String stringValue = (String) value;
-            value = PropertyEditors.getValue(expectedType, stringValue);
-        }
+        //if (value instanceof String && (expectedType != Object.class)) {
+        //    String stringValue = (String) value;
+        //    value = PropertyEditors.getValue(expectedType, stringValue);
+        //}
         return value;
     }
 
@@ -211,21 +206,6 @@
         }
     }
 
-    public static class RecipeComparator implements Comparator<Object> {
-        public int compare(Object left, Object right) {
-            if (!(left instanceof Recipe) && !(right instanceof Recipe)) return 0;
-            if (left instanceof Recipe && !(right instanceof Recipe)) return 1;
-            if (!(left instanceof Recipe) && right instanceof Recipe) return -1;
-
-            float leftPriority = ((Recipe) left).getPriority();
-            float rightPriority = ((Recipe) right).getPriority();
-
-            if (leftPriority > rightPriority) return 1;
-            if (leftPriority < rightPriority) return -1;
-            return 0;
-        }
-    }
-
     public static Type[] getTypeParameters(Class desiredType, Type type) {
         if (type instanceof Class) {
             Class rawClass = (Class) type;

Modified: geronimo/sandbox/blueprint/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/pom.xml?rev=774319&r1=774318&r2=774319&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/pom.xml (original)
+++ geronimo/sandbox/blueprint/pom.xml Wed May 13 13:09:33 2009
@@ -79,11 +79,6 @@
                 <version>4.5</version>
             </dependency>
             <dependency>
-                <groupId>org.apache.xbean</groupId>
-                <artifactId>xbean-reflect</artifactId>
-                <version>3.6-SNAPSHOT</version>
-            </dependency>
-            <dependency>
                 <groupId>cglib</groupId>
                 <artifactId>cglib</artifactId>
                 <version>2.2</version>



Re: svn commit: r774319 - in /geronimo/sandbox/blueprint: ./ blueprint-bundle/ blueprint-core/ blueprint-core/src/main/java/org/apache/xbean/ blueprint-core/src/main/java/org/apache/xbean/recipe/

Posted by Guillaume Nodet <gn...@gmail.com>.
Currently, the whole conversion strategy is broken in blueprint
because we do not use the conversion service as it is supposed too.
Furthermore, the constructor matching and factory method matching
completely fails in some cases because xbean recipes are not 'typed'.
This means that for a given recipe, you don't really know what kind of
object will be created.  This leads to disambiguation not working for
constructors and factory methods.

Let's take a simple example:

class A {
   public A(Map map) {
   }
   public A(Properties props) {
   }
}

with the following definition:

<bean id="a" class="A">
   <argument>
     <props></props>
   </argument>
</bean>

XBean is not able to hande that because a MapRecipe will be created,
but more than one method can be used and the whole disambiguation in
xbean is based on whether a given recipe can create that kind of
objects or not.   You don't have any way to have the best match in
those cases.

So what i did is add a getTypes() method that usually return a single
class (I think multiple values will be needed for references which can
be injected as ServiceReference or proxies).

Anyway, I have no problem discussing the path we want to go, but I
really don't like the current state we're in: the code becomes too
complicated because the roughty had to rewrite the whole factory stuff
in blueprint instead of xbean and it is broken due to not using the
conversion service correctly for disambiguation.
We need to choose one way, as I explained in another thread some time ago:
  * either put what we need in xbean-reflect (factories, better
disambiguation, etc...)
  * or 'fork' it and tweak it to be able to natively handle all the
blueprint requirements
I think the risk of destabilizing openEjb and gbeans are too high to
go for the first solution, so i was heading to the second one.

On Wed, May 13, 2009 at 22:46, Jarek Gawor <jg...@gmail.com> wrote:
> Guillaume,
>
> Can you explain why this is necessary? I really don't want to 'fork'
> xbean-reflect.
>
> Jarek
>
> On Wed, May 13, 2009 at 9:09 AM,  <gn...@apache.org> wrote:
>> Author: gnodet
>> Date: Wed May 13 13:09:33 2009
>> New Revision: 774319
>>
>> URL: http://svn.apache.org/viewvc?rev=774319&view=rev
>> Log:
>> Inline xbean to be able to refactor the conversion mechanism and allow better matching of arguments against constructors / factory methods
>>
>> Added:
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/
>>      - copied from r774242, geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/
>> Removed:
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/AsmParameterNameLoader.java
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/RecipeVisitor.java
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/StaticRecipe.java
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/UnsetPropertiesRecipe.java
>> Modified:
>>    geronimo/sandbox/blueprint/blueprint-bundle/pom.xml
>>    geronimo/sandbox/blueprint/blueprint-core/pom.xml
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/AbstractRecipe.java
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ObjectRecipe.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/RecipeHelper.java
>>    geronimo/sandbox/blueprint/pom.xml
>>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: svn commit: r774319 - in /geronimo/sandbox/blueprint: ./ blueprint-bundle/ blueprint-core/ blueprint-core/src/main/java/org/apache/xbean/ blueprint-core/src/main/java/org/apache/xbean/recipe/

Posted by Jarek Gawor <jg...@gmail.com>.
Guillaume,

Can you explain why this is necessary? I really don't want to 'fork'
xbean-reflect.

Jarek

On Wed, May 13, 2009 at 9:09 AM,  <gn...@apache.org> wrote:
> Author: gnodet
> Date: Wed May 13 13:09:33 2009
> New Revision: 774319
>
> URL: http://svn.apache.org/viewvc?rev=774319&view=rev
> Log:
> Inline xbean to be able to refactor the conversion mechanism and allow better matching of arguments against constructors / factory methods
>
> Added:
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/
>      - copied from r774242, geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/
> Removed:
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/AsmParameterNameLoader.java
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/RecipeVisitor.java
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/StaticRecipe.java
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/UnsetPropertiesRecipe.java
> Modified:
>    geronimo/sandbox/blueprint/blueprint-bundle/pom.xml
>    geronimo/sandbox/blueprint/blueprint-core/pom.xml
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/AbstractRecipe.java
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ObjectRecipe.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/RecipeHelper.java
>    geronimo/sandbox/blueprint/pom.xml
>