aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1341907 - in /aries/branches/blueprint-0.3.2-fixes: ./ blueprint-core/ blueprint-core/src/main/java/org/apache/aries/blueprint/di/ blueprint-core/src/test/java/org/apache/aries/ blueprint-core/src/test/java/org/apache/aries/blueprint/ blue...
Date Wed, 23 May 2012 15:43:12 GMT
Author: dkulp
Date: Wed May 23 15:43:11 2012
New Revision: 1341907

URL: http://svn.apache.org/viewvc?rev=1341907&view=rev
Log:
[ARIES-855] Initial support for loading nested classes
Pull back from trunk

Added:
    aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/test/java/org/apache/aries/blueprint/BeanLoadingTest.java
      - copied, changed from r1341886, aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/BeanLoadingTest.java
    aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/SimpleBean.java
      - copied unchanged from r1341886, aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/SimpleBean.java
    aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/test/resources/test-bean-classes.xml
      - copied unchanged from r1341886, aries/trunk/blueprint/blueprint-core/src/test/resources/test-bean-classes.xml
Modified:
    aries/branches/blueprint-0.3.2-fixes/   (props changed)
    aries/branches/blueprint-0.3.2-fixes/blueprint-core/   (props changed)
    aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/di/AbstractRecipe.java
    aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/test/java/org/apache/aries/  
(props changed)

Propchange: aries/branches/blueprint-0.3.2-fixes/
------------------------------------------------------------------------------
  Merged /aries/trunk/blueprint:r1341886

Propchange: aries/branches/blueprint-0.3.2-fixes/blueprint-core/
------------------------------------------------------------------------------
  Merged /aries/trunk/blueprint/blueprint-core:r1341886

Modified: aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/di/AbstractRecipe.java
URL: http://svn.apache.org/viewvc/aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/di/AbstractRecipe.java?rev=1341907&r1=1341906&r2=1341907&view=diff
==============================================================================
--- aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/di/AbstractRecipe.java
(original)
+++ aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/main/java/org/apache/aries/blueprint/di/AbstractRecipe.java
Wed May 23 15:43:11 2012
@@ -106,10 +106,30 @@ public abstract class AbstractRecipe imp
         if (typeName == null) {
             return null;
         }
+        return doLoadType(typeName, fromClassLoader, true);
+    }
+
+    private ReifiedType doLoadType(String typeName, ClassLoader fromClassLoader, 
+                                   boolean checkNestedIfFailed) {
         try {
             return GenericType.parse(typeName, fromClassLoader != null ? fromClassLoader
: ExecutionContext.Holder.getContext());
         } catch (ClassNotFoundException e) {
-            throw new ComponentDefinitionException("Unable to load class " + typeName + "
from recipe " + this, e);
+            String errorMessage = "Unable to load class " + typeName + " from recipe " +
this;
+            if (checkNestedIfFailed) {
+                int lastDot = typeName.lastIndexOf('.');
+                if (lastDot > 0 && lastDot < typeName.length()) {
+                    String nestedTypeName = typeName.substring(0, lastDot)
+                            + "$" + typeName.substring(lastDot + 1);
+                    try {
+                        return doLoadType(nestedTypeName, fromClassLoader, false);
+                    } catch (ComponentDefinitionException e2) {
+                        // ignore, the recursive call will throw this exception,
+                        // but ultimately the exception referencing the original
+                        // typeName has to be thrown
+                    }
+                }
+            }
+            throw new ComponentDefinitionException(errorMessage, e);
         }
     }
 

Propchange: aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/test/java/org/apache/aries/
------------------------------------------------------------------------------
  Merged /aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries:r1341886

Copied: aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/test/java/org/apache/aries/blueprint/BeanLoadingTest.java
(from r1341886, aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/BeanLoadingTest.java)
URL: http://svn.apache.org/viewvc/aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/test/java/org/apache/aries/blueprint/BeanLoadingTest.java?p2=aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/test/java/org/apache/aries/blueprint/BeanLoadingTest.java&p1=aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/BeanLoadingTest.java&r1=1341886&r2=1341907&rev=1341907&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/BeanLoadingTest.java
(original)
+++ aries/branches/blueprint-0.3.2-fixes/blueprint-core/src/test/java/org/apache/aries/blueprint/BeanLoadingTest.java
Wed May 23 15:43:11 2012
@@ -19,7 +19,7 @@
 package org.apache.aries.blueprint;
 
 import org.apache.aries.blueprint.di.Repository;
-import org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl;
+import org.apache.aries.blueprint.namespace.ComponentDefinitionRegistryImpl;
 import org.apache.aries.blueprint.pojos.SimpleBean;
 
 public class BeanLoadingTest extends AbstractBlueprintTest {



Mime
View raw message