geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r767926 - in /geronimo/xbean/trunk/xbean-reflect/src: main/java/org/apache/xbean/recipe/ObjectGraph.java test/java/org/apache/xbean/recipe/AbstractObjectGraphTest.java
Date Thu, 23 Apr 2009 14:03:02 GMT
Author: gnodet
Date: Thu Apr 23 14:03:01 2009
New Revision: 767926

URL: http://svn.apache.org/viewvc?rev=767926&view=rev
Log:
Fix bad creation order of beans

Modified:
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectGraph.java
    geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/AbstractObjectGraphTest.java

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectGraph.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectGraph.java?rev=767926&r1=767925&r2=767926&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectGraph.java
(original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectGraph.java
Thu Apr 23 14:03:01 2009
@@ -125,7 +125,7 @@
         List<Node> sortedNodes = new ArrayList<Node>(nodes.size());
         LinkedList<Node> leafNodes = new LinkedList<Node>();
         for (Node n : nodes.values()) {
-            if (n.refernceCount == 0) {
+            if (n.referenceCount == 0) {
                 // if the node is totally isolated (no in or out refs),
                 // move it directly to the finished list, so they are first
                 if (n.references.size() == 0) {
@@ -141,8 +141,8 @@
             Node node = leafNodes.removeFirst();
             sortedNodes.add(node);
             for (Node ref : node.references) {
-                ref.refernceCount--;
-                if (ref.refernceCount == 0) {
+                ref.referenceCount--;
+                if (ref.referenceCount == 0) {
                     leafNodes.add(ref);
                 }
             }
@@ -215,11 +215,12 @@
 
                 // if this is a constructor recipe, we need to add a reference link
                 if (constructorRecipes.contains(nestedRecipe)) {
-                    node.refernceCount++;
+                    node.referenceCount++;
                     nestedNode.references.add(node);
                 }
             } else {
                 nestedRecipes.addAll(nestedRecipe.getNestedRecipes());
+                constructorRecipes.addAll(nestedRecipe.getConstructorRecipes());
             }
         }
 
@@ -230,7 +231,7 @@
         String name;
         Recipe recipe;
         final List<Node> references = new ArrayList<Node>();
-        int refernceCount;
+        int referenceCount;
     }
 
     private static class WrapperExecutionContext extends ExecutionContext {

Modified: geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/AbstractObjectGraphTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/AbstractObjectGraphTest.java?rev=767926&r1=767925&r2=767926&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/AbstractObjectGraphTest.java
(original)
+++ geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/AbstractObjectGraphTest.java
Thu Apr 23 14:03:01 2009
@@ -108,13 +108,13 @@
 
         graph = new ObjectGraph(createNewRepository());
         created = graph.createAll("Bends");
-        assertEquals(Arrays.asList("Radiohead", "Bends", "High and Dry", "Fake Plastic Trees"),
new ArrayList<String>(created.keySet()));
+        assertEquals(Arrays.asList("Radiohead", "High and Dry", "Fake Plastic Trees", "Bends"),
new ArrayList<String>(created.keySet()));
 
         graph = new ObjectGraph(createNewRepository());
         created = graph.createAll("Radiohead");
         assertEquals(Arrays.asList("Radiohead"), new ArrayList<String>(created.keySet()));
         created = graph.createAll("Bends");
-        assertEquals(Arrays.asList("Bends", "High and Dry", "Fake Plastic Trees"), new ArrayList<String>(created.keySet()));
+        assertEquals(Arrays.asList("High and Dry", "Fake Plastic Trees", "Bends"), new ArrayList<String>(created.keySet()));
     }
 
     public void testCreateUnknown() {
@@ -149,6 +149,7 @@
     }
 
     public void testCircularDependency() {
+        // Add a constructor dependency
         Repository repository = createNewRepository();
         ObjectRecipe recipe = (ObjectRecipe) repository.get("Radiohead");
         recipe.setConstructorArgNames(new String[] {"name", "albums"});
@@ -163,10 +164,11 @@
                     expected.getCircularDependency());
         }
 
-
+        // Add a non constructor dependency
+        // This will fail too, unless Option.LAZY_ASSIGNMENT is set
         repository = createNewRepository();
         recipe = (ObjectRecipe) repository.get("Radiohead");
-        recipe.setConstructorArgNames(new String[] {"name", "albums"});
+        recipe.setConstructorArgNames(new String[] {"name"});
         recipe.setProperty("albums", new CollectionRecipe(Arrays.asList(repository.get("Bends"))));
 
         graph = new ObjectGraph(repository);



Mime
View raw message